<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class log {

    private $db = NULL;
    private $config = NULL;

    public function __construct($config = NULL, $db = NULL) {
        $this->db = $db;
        $this->config = $config;
    }

    private function addtologfile($message) {
        $r = file_put_contents($this->config["Options"]["log_file"], $message . "\n", FILE_APPEND);
        return $r;
    }

    public function addmessage($message, $onlytodb = false) {
        if (!$onlytodb)
            print $message . "\n";
        if ($this->config["Options"]["log_disk"])
            $this->addtologfile($message);
        else
            $this->db->addtolog("N/A", $message);
    }

    public function print_message($message) {
        print $message . "\n";
    }

}

?>
